var statDocument=null;
$(function () {
    statDocument=new StatDocument();
});
(function(){
    var StatDocument = window.StatDocument = function(){
        return new StatDocument.prototype.init();

    };
    StatDocument.fn = StatDocument.prototype = {
        urls:{
            statByApplyItem: CommonUtils.siteName+"gdp/regionGdp/statByApplyItem",
            statApplyCount: CommonUtils.siteName+"gdp/regionGdp/statApplyCount",
            statApplyCountByTech: CommonUtils.siteName+"gdp/regionGdp/statApplyCountByTech",
            statTotalAuditCount: CommonUtils.siteName+"gdp/regionGdp/statTotalAuditCount",
            statUnAuditCount: CommonUtils.siteName+"gdp/regionGdp/statUnAuditCount",
            statByCheckName: CommonUtils.siteName+"gdp/regionGdp/statByCheckName",
            statApplyItemByYear: CommonUtils.siteName+"gdp/regionGdp/statApplyItemByYear",
            statCheckNumsByYear: CommonUtils.siteName+"gdp/regionGdp/statCheckNumsByYear",
            statCheckNumsAndNameByYear: CommonUtils.siteName+"gdp/regionGdp/statCheckNumsAndNameByYear",
        },
        BxArrMonth:[1,2,3,4,5,6,7,8,9,10,11,12],
        init:function () {
            this.initOpt();
            this.initEvent();
            this.statApplyCount();
            this.statApplyCountByTech();
            this.statTotalAuditCount();
            this.statUnAuditCount();
            this.statApplyItemByYear();
            return this;
        },
        initOpt:function () {
            var that=this;

        },
        initEvent:function () {
            var that=this;
            var laydate = layui.laydate;
            //初始化laydate实例
            laydate.render({
                elem: '#J_startLaydate'
            });
            laydate.render({
                elem: '#J_endLaydate'
            });
            laydate.render({
                elem: '#J_selectStatYear',
                type:'year',
                position:'fixed',
                ready:function (date) {
                    initYear=date.year;
                }
            });
            
            $("#J_btnStat").click(function () {
                var checkStatType=$("#J_selectCheckStatType").val();
                if(checkStatType=="按月份统计申请件数"){
                    that.statApplyItemByYear();
                }else if(checkStatType=="按申报事项统计"){
                    that.statByApplyItem();
                }else if(checkStatType=="按审核员统计"){
                    that.statByCheckName();
                }else if(checkStatType=="按月份统计审核次数"){
                    that.statCheckNumsByYear();
                }else if(checkStatType=="按月份统计每人审核次数"){
                    that.statCheckNumsAndNameByYear();
                }

            })


            $("#J_selectCheckStatType").on('change',function(){
                var checkStatType=$("#J_selectCheckStatType").val();
                if(checkStatType=="按月份统计申请件数"){
                    $("#J_statYear").css("display","inline");
                    $("#J_statStartEnd").css("display","none");
                    that.statApplyItemByYear();
                }else if(checkStatType=="按申报事项统计"){
                    $("#J_statYear").css("display","none");
                    $("#J_statStartEnd").css("display","inline");
                    $("#J_showStatData").css("display","none");
                    that.statByApplyItem();
                }else if(checkStatType=="按审核员统计"){
                    $("#J_statYear").css("display","none");
                    $("#J_statStartEnd").css("display","inline");
                    $("#J_showStatData").css("display","none");
                    that.statByCheckName();
                }else if(checkStatType=="按月份统计审核次数"){
                    $("#J_statYear").css("display","inline");
                    $("#J_statStartEnd").css("display","none");
                    that.statCheckNumsByYear();
                }else if(checkStatType=="按月份统计每人审核次数"){
                    $("#J_statYear").css("display","inline");
                    $("#J_statStartEnd").css("display","none");
                    that.statCheckNumsAndNameByYear();
                }
            });

            // $("#J_selectCheckStatType").change(function () {
            //
            //
            // })


        },

        //统计总申请个数
        statApplyCount:function(){
            var that=this;
            $.ajax({
                url:that.urls.statApplyCount,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                   $("#J_statApplyCount").html(result);
                }
            });
        },

        //统计总的技术审查通过个数
        statApplyCountByTech:function(){
            var that=this;
            $.ajax({
                url:that.urls.statApplyCountByTech,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    $("#J_statApplyCountByTech").html(result);
                }
            });
        },

        //统计总的审查次数
        statTotalAuditCount:function(){
            var that=this;
            $.ajax({
                url:that.urls.statTotalAuditCount,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    $("#J_statTotalAuditCount").html(result);
                }
            });
        },



        //统计总的审查次数
        statUnAuditCount:function(){
            var that=this;
            $.ajax({
                url:that.urls.statUnAuditCount,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    $("#J_statUnAuditCount").html(result);
                }
            });
        },

        /**
         * 统计申请事项
         */
        statByApplyItem:function(){
            var that=this;
            var startTime=$("#J_startLaydate").val();
            var endTime=$("#J_endLaydate").val();
            $.ajax({
                url:that.urls.statByApplyItem,
                type: 'get',
                data:{startTime:startTime,
                    endTime:endTime},
                dataType: 'json',
                async: false,
                success: function (result) {
                    var xdatas=[],ydatas=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var recordName=data[i].applyItem;
                            xdatas.push(recordName);
                            var total=data[i].total;
                            ydatas.push(total);
                        }
                        that.showStatByApplyItem(xdatas,ydatas);
                    }
                }
            });
        },


        /**
         * 显示事项统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showStatByApplyItem:function (xdatas,ydatas) {
            var option = {
                color: ['#006699'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"(件)"
                    }
                },

                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name:'件',
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '件',
                        barGap: 0,
                        type: 'bar',
                        data:ydatas,
                        itemStyle: {        //上方显示数值
                            normal: {
                                label: {
                                    show: true, //开启显示
                                    position: 'top', //在上方显示
                                    textStyle: { //数值样式
                                        color: 'black',
                                        fontSize: 16
                                    }
                                }
                            }
                        },
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statByApplyItem'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },


        /**
         * 审核员统计
         */
        statByCheckName:function(){
            var that=this;
            var startTime=$("#J_startLaydate").val();
            var endTime=$("#J_endLaydate").val();
            $.ajax({
                url:that.urls.statByCheckName,
                type: 'get',
                data:{startTime:startTime,
                    endTime:endTime},
                dataType: 'json',
                async: false,
                success: function (result) {
                    debugger
                    var xdatas=[],ydatas=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var checkName=data[i].checkName;
                            xdatas.push(checkName);
                            var total=data[i].total;
                            ydatas.push(total);
                        }
                        that.showStatByApplyItem(xdatas,ydatas);
                    }
                }
            });
        },


        /**
         * 按月统计某年的数
         */
        statApplyItemByYear:function(){
            var that=this;
            var year=$("#J_selectStatYear").val();
            $.ajax({
                url:that.urls.statApplyItemByYear,
                type: 'get',
                data:{year:year},
                dataType: 'json',
                async: false,
                success: function (result) {
                    var xdatas1=[],ydatas1=[],xdatas2=[],ydatas2=[],xdatas3=[],ydatas3=[],xdatas4=[],ydatas4=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var month=data[i].month;
                            var total=data[i].total;
                            if(data[i].applyItem=="基本信息变更"){
                                xdatas1.push(month);
                                ydatas1.push(total);
                            }else if(data[i].applyItem=="专业类别变更"){
                                xdatas2.push(month);
                                ydatas2.push(total);
                            }else if(data[i].applyItem=="补充和修改数据"){
                                xdatas3.push(month);
                                ydatas3.push(total);
                            }else if(data[i].applyItem=="资质申请"){
                                xdatas4.push(month);
                                ydatas4.push(total);
                            }
                        }

                        that.showStatTableData(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,"件");
                        // that.showStatResultLine(xdatas,ydatas);
                        that.showStatResultLine2(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,"件");
                    }
                }
            });
        },

        /**
         * 按月统计某年的审核次数
         */
        statCheckNumsByYear:function(){
            var that=this;
            var year=$("#J_selectStatYear").val();
            $.ajax({
                url:that.urls.statCheckNumsByYear,
                type: 'get',
                data:{year:year},
                dataType: 'json',
                async: false,
                success: function (result) {
                    debugger
                    var xdatas1=[],ydatas1=[],xdatas2=[],ydatas2=[],xdatas3=[],ydatas3=[],xdatas4=[],ydatas4=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var month=data[i].month;
                            var total=data[i].total;
                            if(data[i].applyItem=="基本信息变更"){
                                xdatas1.push(month);
                                ydatas1.push(total);
                            }else if(data[i].applyItem=="专业类别变更"){
                                xdatas2.push(month);
                                ydatas2.push(total);
                            }else if(data[i].applyItem=="补充和修改数据"){
                                xdatas3.push(month);
                                ydatas3.push(total);
                            }else if(data[i].applyItem=="资质申请"){
                                xdatas4.push(month);
                                ydatas4.push(total);
                            }
                        }

                        that.showStatTableData(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,"次");
                        // that.showStatResultLine(xdatas,ydatas);
                        that.showStatResultLine2(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,"次");
                    }
                }
            });
        },


        //按月统计每人审核次数
        statCheckNumsAndNameByYear:function(){
            var that=this;
            var year=$("#J_selectStatYear").val();
            $.ajax({
                url:that.urls.statCheckNumsAndNameByYear,
                type: 'get',
                data:{year:year},
                dataType: 'json',
                async: false,
                success: function (result) {
                    debugger
                    var xdatas1=[],ydatas1=[],ydatas2=[],ydatas3=[],ydatas4=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var month=data[i].month;
                            var total=data[i].total;
                            if(data[i].checkName=="林立恒"){
                                xdatas1.push(month);
                                ydatas1.push(total);
                            }else if(data[i].checkName=="冯清"){
                                ydatas2.push(total);
                            }else if(data[i].checkName=="张海明"){
                                ydatas3.push(total);
                            }else if(data[i].checkName=="郑文汉"){
                                ydatas4.push(total);
                            }
                        }

                        that.showStatCheckNumsAndNameByYearTableData(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,"次");
                        that.showStatCheckNumsAndNameByYearLine(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,"次");
                    }
                }
            });
        },

        showStatTableData:function(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,unit){
          var that=this;
          var html='';
          for(var i=0;i<xdatas1.length;i++){
              var total=parseInt(ydatas1[i])+parseInt(ydatas2[i])+parseInt(ydatas3[i])+parseInt(ydatas4[i]);
              html+=xdatas1[i]+'累计审核'+total+unit+'。其中基本信息变更：'+ydatas1[i]+unit+'；'+'专业类别变更：'+ydatas2[i]+unit+'；'+'补充和修改数据：'+ydatas3[i]+unit+'；'+'资质申请：'+ydatas4[i]+unit+'。<br>';
          }
          $("#J_showStatData").html(html);
            $("#J_showStatData").css("display","inline");
        },


        showStatCheckNumsAndNameByYearTableData:function(xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,unit){
            var that=this;
            var html='';
            for(var i=0;i<xdatas1.length;i++){
                var total1=0;
                var total2=0;
                var total3=0;
                var total4=0;
                if(ydatas1[i]!=""&&ydatas1[i]!=undefined)
                    total1=parseInt(ydatas1[i]);
                if(ydatas2[i]!=""&&ydatas2[i]!=undefined)
                    total2=parseInt(ydatas2[i]);
                if(ydatas3[i]!=""&&ydatas3[i]!=undefined)
                    total3=parseInt(ydatas3[i]);
                if(ydatas4[i]!=""&&ydatas4[i]!=undefined)
                    total4=parseInt(ydatas4[i]);



                var total=total1+total2+total3+total4;
                html+=xdatas1[i]+'累计审核'+total+unit+'。林立恒：'+total1+unit+'；'+'冯清：'+total2+unit+'；'+'张海明：'+total3+unit+'；'+'郑文汉：'+total4+unit+'。<br>';
            }
            $("#J_showStatData").html(html);
            $("#J_showStatData").css("display","inline");
        },
        /**
         * 显示线状统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showStatResultLine:function (xdatas,ydatas) {
            var option = {
                // color: ['#006699', '#4cabce'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"(宗)"
                            +"<br>"+params[1].seriesName+":"+ params[1].data+"(宗)";
                    }
                },
                legend: {
                    data: ['申报数']
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name: '件',
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '提交数',
                        type: 'line',
                        data:ydatas,
                        itemStyle: {        //上方显示数值
                            normal: {
                                label: {
                                    show: true, //开启显示
                                    position: 'top', //在上方显示
                                    textStyle: { //数值样式
                                        color: 'black',
                                        fontSize: 16
                                    }
                                }
                            }
                        },
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statByApplyItem'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },

        showStatResultLine2:function (xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,unit) {
            var option = {
                color: ['purple', '#4cabce', 'red', 'blue'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"("+unit+")"
                            +"<br>"+params[1].seriesName+":"+ params[1].data+"("+unit+")"
                            +"<br>"+params[2].seriesName+":"+ params[2].data+"("+unit+")"
                            +"<br>"+params[3].seriesName+":"+ params[3].data+"("+unit+")";
                    }
                },
                legend: {
                    data: ['申报数']
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas1,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name: unit,
                        type: 'value'
                    }
                ],
                legend:{
                    data:['基本信息变更','专业类别变更','补充和修改数据','资质申请']
                },
                series: [
                    {
                        name: '基本信息变更',
                        type: 'line',
                        data:ydatas1,
                        // itemStyle: {        //上方显示数值
                        //     normal: {
                        //         color: 'black',
                        //         // label: {
                        //         //     show: true, //开启显示
                        //         //     position: 'top', //在上方显示
                        //         //     textStyle: { //数值样式
                        //         //         color: 'black',
                        //         //         fontSize: 16
                        //         //     }
                        //         // }
                        //     }
                        // },
                    },
                    {
                        name: '专业类别变更',
                        type: 'line',
                        data:ydatas2,
                        // itemStyle: {        //上方显示数值
                        //     normal: {
                        //         color: 'purple',
                        //         // label: {
                        //         //     show: true, //开启显示
                        //         //     position: 'top', //在上方显示
                        //         //     textStyle: { //数值样式
                        //         //         color: 'purple',
                        //         //         fontSize: 16
                        //         //     }
                        //         // }
                        //     }
                        // },
                    },{
                        name: '补充和修改数据',
                        type: 'line',
                        data:ydatas3,
                        // itemStyle: {        //上方显示数值
                        //     normal: {
                        //         color: 'blue',
                        //         // label: {
                        //         //     show: true, //开启显示
                        //         //     position: 'top', //在上方显示
                        //         //     textStyle: { //数值样式
                        //         //         color: 'blue',
                        //         //         fontSize: 16
                        //         //     }
                        //         // }
                        //     }
                        // },
                    },{
                        name: '资质申请',
                        type: 'line',
                        data:ydatas4,
                        // itemStyle: {        //上方显示数值
                        //     normal: {
                        //         color: 'red',
                        //         // label: {
                        //         //     show: true, //开启显示
                        //         //     position: 'top', //在上方显示
                        //         //     textStyle: { //数值样式
                        //         //         color: 'red',
                        //         //         fontSize: 16
                        //         //     }
                        //         // }
                        //     }
                        // },
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statByApplyItem'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },


        showStatCheckNumsAndNameByYearLine:function (xdatas1,ydatas1,ydatas2,ydatas3,ydatas4,unit) {
            var option = {
                color: ['purple', '#4cabce', 'red', 'blue'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"("+unit+")"
                            +"<br>"+params[1].seriesName+":"+ params[1].data+"("+unit+")"
                            +"<br>"+params[2].seriesName+":"+ params[2].data+"("+unit+")"
                            +"<br>"+params[3].seriesName+":"+ params[3].data+"("+unit+")";
                    }
                },
                legend: {
                    data: ['申报数']
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas1,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name: unit,
                        type: 'value'
                    }
                ],
                legend:{
                    data:['林立恒','冯清','张海明','郑文汉']
                },
                series: [
                    {
                        name: '林立恒',
                        type: 'line',
                        data:ydatas1
                    },
                    {
                        name: '冯清',
                        type: 'line',
                        data:ydatas2
                    },{
                        name: '张海明',
                        type: 'line',
                        data:ydatas3
                    },{
                        name: '郑文汉',
                        type: 'line',
                        data:ydatas4
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statByApplyItem'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },


        /**
         * 档案统计
         */
        statDocumentByYear:function () {
            var that=this;
            $.ajax({
                url:that.urls.statDocByYear,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    var xdatas=[],persondatas=[],unitdatas=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        if(data.length>5)
                            length=4;
                        for(var i=0;i<length;i++){
                            var year=data[i].YEAR;
                            xdatas.push(year+"年");
                            var personDoc=data[i].personDoc;
                            persondatas.push(personDoc);
                            var unitDoc=data[i].unitDoc;
                            unitdatas.push(unitDoc);
                        }
                        // that.showDocStatResultBar(xdatas,persondatas,unitdatas);
                        that.showDocStatResultLine(xdatas,persondatas,unitdatas);
                    }
                }
            });
        },

        /**
         * 显示档案柱状统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showDocStatResultBar:function (xdatas,persondatas,unitdatas) {
            var option = {
                color: ['#006699', '#4cabce'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                legend: {
                    data: ['个人档案','单位档案']
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '个人档案',
                        barGap: 0,
                        type: 'bar',
                        data:persondatas
                    },
                    {
                        name: '单位档案',
                        type: 'bar',
                        data: unitdatas
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statDocument'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },

        /**
         * 显示档案线状统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showDocStatResultLine:function (xdatas,persondatas,unitdatas) {
            var option = {
                // color: ['#006699', '#4cabce'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"(宗)"
                            +"<br>"+params[1].seriesName+":"+ params[1].data+"(宗)";
                    }
                },
                legend: {
                    data: ['个人档案','单位档案']
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name: '宗',
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '个人档案',
                        type: 'line',
                        data:persondatas
                    },
                    {
                        name: '单位档案',
                        type: 'line',
                        data: unitdatas
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statDocument'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },

        /**
         * 按登记类型统计
         */
        statDocByRecordType:function () {
            var that=this;
            $.ajax({
                url:that.urls.statDocByRecordType,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    var xdatas=[],ydatas=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var recordName=data[i].recordName;
                            xdatas.push(recordName);
                            var total=data[i].total;
                            ydatas.push(total);
                        }
                        // that.showDocStatResultByRecordTypeBar(xdatas,ydatas);
                        that.showDocStatResultByRecordTypePie(xdatas,ydatas);
                    }
                }
            });
        },

        /**
         * 显示档案柱状统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showDocStatResultByRecordTypeBar:function (xdatas,ydatas) {
            var option = {
                color: ['#006699'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '档案',
                        barGap: 0,
                        type: 'bar',
                        data:ydatas
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statDocumentByRecordType'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },
        /**
         * 显示档案饼状统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showDocStatResultByRecordTypePie:function (xdatas,ydatas) {
            var seriesData=[];
            var legendData=[];
            var selected=[];
            var count=ydatas.length;
            for (var i = 0; i < count; i++) {
                var name=xdatas[i];
                var value=ydatas[i];
                legendData.push(name);
                seriesData.push({
                    name: name,
                    value: value
                });
                selected[name] = i < 6;
            }

            var option = {
                grid: {
                    containLabel: true
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b} : {c}(宗)({d}%)'
                },
                legend: {
                    type: 'scroll',
                    orient: 'vertical',
                    right: 10,
                    top: 20,
                    bottom: 20,
                    data: legendData,
                    selected:selected
                },
                series: [
                    {
                        name: '档案',
                        type: 'pie',
                        radius: '55%',
                        center: ['40%', '50%'],
                        data: seriesData,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statDocumentByRecordType'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },
        /**
         * 按月档案统计
         */
        statDocumentByMonth:function () {
            var that=this;
            $.ajax({
                url:that.urls.statDocumentByMonth,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    var xdatas=[],persondatas=[],unitdatas=[];
                    if(result.code===200){
                        var data=result.data;
                        for(var i=0;i<that.BxArrMonth.length;i++){
                            persondatas.push(0);
                            unitdatas.push(0);
                            xdatas.push(that.BxArrMonth[i]+"月")
                        }
                        for(var i=0;i<data.length;i++){
                            var month=data[i].MONTH;
                            persondatas[month-1]=data[i].personDoc;
                            var unitDoc=data[i].unitDoc;
                            unitdatas[month-1]=unitDoc;
                        }
                        // that.showDocStatResultBar(xdatas,persondatas,unitdatas);
                        that.showDocStatResultLineByMonth(xdatas,persondatas,unitdatas);
                    }
                }
            });
        },

        /**
         * 显示档案线状统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showDocStatResultLineByMonth:function (xdatas,persondatas,unitdatas) {
            var option = {
                // color: ['#006699', '#4cabce'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"(宗)"
                            +"<br>"+params[1].seriesName+":"+ params[1].data+"(宗)";
                    }
                },
                legend: {
                    data: ['个人档案','单位档案']
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name:'宗',
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '个人档案',
                        type: 'line',
                        data:persondatas
                    },
                    {
                        name: '单位档案',
                        type: 'line',
                        data: unitdatas
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statDocumentByMonth'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        },


        /**
         * 按权利类型统计
         */
        statDocByRightType:function () {
            var that=this;
            $.ajax({
                url:that.urls.statDocByRightType,
                type: 'get',
                data:{},
                dataType: 'json',
                async: false,
                success: function (result) {
                    var xdatas=[],ydatas=[];
                    if(result.code===200){
                        var data=result.data;
                        var length=data.length;
                        for(var i=0;i<length;i++){
                            var rightTypeName=data[i].rightTypeName;
                            xdatas.push(rightTypeName);
                            var total=data[i].total;
                            ydatas.push(total);
                        }
                        that.showDocStatResultByRightType(xdatas,ydatas);
                    }
                }
            });
        },

        /**
         * 显示权利类型档案统计结果
         * @param xdatas
         * @param persondatas
         * @param unitdatas
         */
        showDocStatResultByRightType:function (xdatas,ydatas) {
            var option = {
                color: ['#006699'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    },
                    formatter:function (params) {
                        return params[0].name
                            +"<br>"+params[0].seriesName+":" +params[0].data+"(宗)"
                    }
                },
                grid: {
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: xdatas,
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        name:'宗',
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '档案',
                        barGap: 0,
                        type: 'bar',
                        data:ydatas
                    }
                ]
            };
            var myChart = echarts.init(document.getElementById('J_statDocumentByRightType'));
            myChart.clear();
            myChart.setOption(option);
            myChart.resize();
        }
        
    };
    StatDocument.fn.init.prototype = StatDocument.fn;
})();




